﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Data.Entity;

namespace BL
{
    public class MenuItem
    {
        [Key]
        public virtual int ID { get; set; }

        public virtual string Name { get; set; }


        private List<Location> _Locations;
        
        public virtual List<Location> Locations
        {
            get { return _Locations ?? (_Locations = new List<Location>()); }
            set { _Locations = value; }
        }

        [JsonIgnore]
        public virtual MenuItem Parent { get; set; }

        private List<MenuItem> _Children;

        public virtual List<MenuItem> Children
        {
            get { return _Children ?? (_Children = new List<MenuItem>()); }
            set { _Children = value; }
        }

        public virtual bool ShowFocusing { get; set; }
                 
        public virtual bool ShowRouting { get; set; }
                 
        public virtual bool ShowLogging { get; set; }
                 
        public virtual string PictureName { get; set; }

        public static List<MenuItem> GetMainMenus(Context context)
        {
            List<MenuItem> menus = null;

             menus = context.Menus.Where(m => m.Parent == null).ToList();


            return menus;
        }
    }
}
